package com.taichuan.selfcheck.ad;


/**
 * Created by OISNY on 2016/7/14.
 */
public class ADArea {
    private PlayedType playedType = PlayedType.IMAGE;
    private PlayedType allowedPlayType = PlayedType.ALL;
    private boolean autoFix = false;
    private EADArea mEADArea;

    public ADArea(EADArea eArea) {
        this(eArea, false);
    }

    public ADArea(EADArea eArea, boolean autoFix) {
        this(eArea, autoFix, PlayedType.ALL);
    }

    public ADArea(EADArea eArea, boolean autoFix, PlayedType allowedPlayType) {
        mEADArea = eArea;
        this.autoFix = autoFix;
        this.allowedPlayType = allowedPlayType;
    }

    public EADArea getEADArea() {
        return mEADArea;
    }

    /**
     * 判断设备是否登录
     * @return
     */
    public boolean isLogined() {
//        Session session = PersistentManager.get().getSession();
//        return session != null && session.isValided();
        return true;
    }


    private boolean isAllowedPlay(PlayedType playedType) {
        return this.allowedPlayType == PlayedType.ALL || this.allowedPlayType == playedType;
    }
//
//    public boolean isPlayedImage() {
//        return isAllowedPlay(PlayedType.IMAGE) && PropertyPreference.get()
//                .getBoolean(PropertyKey.CFG_SET_ISPLAYPICTURE, PropertyDefaultValue.CFG_SET_ISPLAYPICTURE);
//    }
//
    public boolean isPlayedVideo() {
//        return isAllowedPlay(PlayedType.VIDEO) && PropertyPreference.get()
//                .getBoolean(PropertyKey.CFG_SET_ISPLAYVIDEO, PropertyDefaultValue.CFG_SET_ISPLAYVIDEO);
        return true;
    }
//
//    public int getImageLoopDelay() {
//        return PropertyPreference.get()
//                .getInt(PropertyKey.CFG_SET_SWITCHDELAY, PropertyDefaultValue.CFG_SWITCH_DELAY);
//    }

    public boolean isAutoFix() {
        return autoFix;
    }

    public void setAutoFix(boolean autoFix) {
        this.autoFix = autoFix;
    }

    public PlayedType getPlayedType() {
        return playedType;
    }

    public void setPlayedType(PlayedType playedType) {
        this.playedType = playedType;
    }

    public PlayedType getAllowedPlayType() {
        return allowedPlayType;
    }

    public void setAllowedPlayType(PlayedType allowedPlayType) {
        this.allowedPlayType = allowedPlayType;
    }

    public enum PlayedType {
        NONE, IMAGE, VIDEO, ALL
    }
}
